package com.runshu.newsmartark.entity;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.runshu.newsmartark.util.ListUtils;

import java.util.Arrays;
import java.util.List;

/**
 * Demo class
 *
 * @author yu
 * @date 2020/7/30
 * @decs：
 */
@Entity(tableName = "UserInfoEntity")
public class UserInfoEntity implements Parcelable {
    @PrimaryKey
    @ColumnInfo(name = "token")
    public Long id;
    @ColumnInfo(name = "icCard")
    private String icCard;
    @ColumnInfo(name = "userName")
    private String userName;
    @ColumnInfo(name = "userCode")
    private String userCode;
    @ColumnInfo(name = "userPhone")
    private String userPhone;
    @ColumnInfo(name = "faceCode")
    private String faceCode;
    @ColumnInfo(name = "createTime")
    private String createTime;

    public void setFaceCode(String faceCode) {
        this.faceCode = faceCode == null ? "" : faceCode;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getIcCard() {
        return icCard == null ? "" : icCard;
    }

    public void setIcCard(String icCard) {
        this.icCard = icCard == null ? "" : icCard;
    }

    public String getUserName() {
        return userName == null ? "" : userName;
    }

    public void setUserName(String userName) {
        this.userName = userName == null ? "" : userName;
    }

    public String getUserCode() {
        return userCode == null ? "" : userCode;
    }

    public void setUserCode(String userCode) {
        this.userCode = userCode == null ? "" : userCode;
    }

    public String getUserPhone() {
        return userPhone == null ? "" : userPhone;
    }

    public void setUserPhone(String userPhone) {
        this.userPhone = userPhone == null ? "" : userPhone;
    }

    public String getFaceCode() {
        return faceCode == null ? "" : faceCode;
    }

    public void setFaceCode(byte[] faceCode) {
        this.faceCode = Arrays.toString(faceCode);
    }

    public String getCreateTime() {
        return createTime == null ? "" : createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime == null ? "" : createTime;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(this.id);
        dest.writeString(this.icCard);
        dest.writeString(this.userName);
        dest.writeString(this.userCode);
        dest.writeString(this.userPhone);
        dest.writeString(this.faceCode);
        dest.writeString(this.createTime);
    }

    public void readFromParcel(Parcel source) {
        this.id = (Long) source.readValue(Long.class.getClassLoader());
        this.icCard = source.readString();
        this.userName = source.readString();
        this.userCode = source.readString();
        this.userPhone = source.readString();
        this.faceCode = source.readString();
        this.createTime = source.readString();
    }

    public UserInfoEntity() {
    }

    protected UserInfoEntity(Parcel in) {
        this.id = (Long) in.readValue(Long.class.getClassLoader());
        this.icCard = in.readString();
        this.userName = in.readString();
        this.userCode = in.readString();
        this.userPhone = in.readString();
        this.faceCode = in.readString();
        this.createTime = in.readString();
    }

    public static final Creator<UserInfoEntity> CREATOR = new Creator<UserInfoEntity>() {
        @Override
        public UserInfoEntity createFromParcel(Parcel source) {
            return new UserInfoEntity(source);
        }

        @Override
        public UserInfoEntity[] newArray(int size) {
            return new UserInfoEntity[size];
        }
    };
}